package buffer;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class CopyFile {
	public static void main(String[] args) throws IOException{
		FileInputStream fis = new FileInputStream("a.txt");
		FileChannel fc = fis.getChannel();
		ByteBuffer buffer = ByteBuffer.allocate(fis.available());
		fc.read(buffer);
		
		FileOutputStream fos = new FileOutputStream("copy.txt");
		FileChannel fc2 = fos.getChannel();
		buffer.flip();
		fc2.write(buffer);
		
		fis.close();
		fos.close();
	}
}
